const formate = {
  formate(n){
    let date = new Date();
    let yy = date.getFullYear();
    let mm = date.getMonth()+1;
    let dd = date.getDate();
    let arr_31 = [1,3,5,7,8,10,12];
    let arr_30 = [4,6,9,11];
    let new_yy = null;
    let new_mm = null;
    let new_dd = null;
    if(n==0){
      return yy+'-'+mm+'-'+dd
    }
    if(mm+n>12){
      new_yy = yy + 1;
      new_mm = mm + n - 12;
      new_dd = dd - 1;
    }
    else{
      new_yy = yy;
      new_mm = mm + n;
      new_dd = dd - 1;
    }
    if(new_dd===0){
      new_mm--;
      if(arr_31.indexOf(new_mm)>0){
        new_dd = 31;
      }
      else if(arr_30.indexOf(new_mm>0)){
        new_dd = 30;
      }
      else if(new_mm===2){
        new_dd = new_yy%4===0?29:28;
      }
    }
    if(new_mm===0){
      new_yy--;
      new_mm = 12;
    }
    new_mm = new_mm<10?'0'+new_mm:new_mm;
    new_dd = new_dd<10?'0'+new_dd:new_dd;

    return new_yy+'-'+new_mm+'-'+new_dd
  }
}
export default formate



